export function promisify (func, params) {
  return new Promise((resolve, reject) => {
    try {
      if (params.success) {
        const oldSuccess = params.success
        params.success = (res) => {
          oldSuccess(res, resolve, reject)
        }
      } else {
        params.success = resolve
      }
      params.fail = reject
      func(params)
    } catch (ex) {
      reject(ex)
    }
  })
}